package com.github.postsanf.yinian.activity;

import android.os.Bundle;
import android.widget.ProgressBar;

import com.github.postsanf.yinian.BaseActivity;
import com.github.postsanf.yinian.R;
import com.github.postsanf.yinian.widget.MyJCVideoPlayerStandard;

import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;

public class LocalManageVideoPreviewActivity extends BaseActivity {
    private MyJCVideoPlayerStandard videoView;
    private ProgressBar progressBar;
    private String localVideopath;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit_videopreview);
        initView();
    }

    private void initView() {
        localVideopath = getIntent().getStringExtra("localVideopath");
//        Uri uri = Uri.parse(localVideopath);
//        progressBar = (ProgressBar) findViewById(R.id.videoView_par);
        videoView = (MyJCVideoPlayerStandard) this.findViewById(R.id.videoView);
//        videoView.setMediaController(new MediaController(this));
//        videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
//
//            @Override
//            public void onPrepared(MediaPlayer mp) {
//                progressBar.setVisibility(View.GONE);
//            }
//        });
//        videoView.setOnCompletionListener(new MyPlayerOnCompletionListener());
//        videoView.setVideoURI(uri);
//        videoView.start();

        videoView.setUp(localVideopath, "");
        videoView.ivStart.performClick();
    }

//    class MyPlayerOnCompletionListener implements MediaPlayer.OnCompletionListener {
//
//        @Override
//        public void onCompletion(MediaPlayer mp) {
////            Toast.makeText(LocalManageVideoPreviewActivity.this, "完成", Toast.LENGTH_SHORT).show();
//        }
//    }

//    @Override
//    public void onBackPressed() {
//        super.onBackPressed();
//        if (getIntent() != null && getIntent().getBooleanExtra("fromPerssion", false)) {
//            finish();
//        } else {
//            startActivity(new Intent(LocalManageVideoPreviewActivity.this, StealEachPerssionActivity.class));
//            finish();
//        }
//    }


    @Override
    protected void onDestroy() {
        JCVideoPlayer.releaseAllVideos();
        super.onDestroy();
    }
}
